#ifndef _SCHEMA_MANAGER_H_
#define _SCHEMA_MANAGER_H_

#include "/usr/include/mysql/mysql.h"
#include "url.h"
#include <vector>
using namespace std;

#define KEYWORD_SCHEMA_THREAD_COUNT 10
#define PENDING_SCHEMA_THREAD_COUNT 10
#define DICT_SCHEMA_THREAD_COUNT 10
#define URL_SCHEMA_THREAD_COUNT 10
#define INVALID_SCHEMA_THREAD_COUNT 10

typedef int(*schema_operate_fun)(void*);

struct schema_op_t
{
	schema_operate_fun op_ok;
	schema_operate_fun op_fail;
	
};

int init_schema_op(schema_op_t* schema_op,
				   schema_operate_fun op_ok,
				   schema_operate_fun op_fail);


struct schema_t
{
	void* data;
	vector<schema_op_t> schema_ops;
	schema_operate_fun func_release;
	int next;
	bool next_op;
};
int init_schema(schema_t* schema, void* data,
				schema_operate_fun op_release);
void add_schema_op(schema_t* schema, schema_op_t* schema_op);
void del_schema(schema_t* schema);



int go_next_schema(schema_t* schema, int ret);


enum eTABLE_OP
{
	INSERT_TABLE = 0x01,
	DELETE_TABLE = 0x02,
	UPDATE_TABLE = 0x04,
	SELECT_TABLE = 0x08,
	COUNT_TABLE =  0x10,
};

struct table_op_t
{
	schema_t* schema;
	eTABLE_OP op;
};
table_op_t* creat_table_op(schema_t* schema, eTABLE_OP op);
void del_table_op(table_op_t* table_op);

struct page_t;
int add_page_to_schema(page_t* page);	


int remove_invalid_url(url_t* url);//remove from pending and add to invalid



#endif
